]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ibusManager: Use Map to store engines
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Jun 2019 23:02:34 +0000 (01:02 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Fri, 5 Jul 2019 11:32:31 +0000 (11:32 +0000)
This is a clear case of key->value mapping, so using the corresponding
data type makes sense.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612

js/misc/ibusManager.js

index 338542a1364108187ddb21156703377da8aad2aa..5a0d2906af282b4742084dad80f8d2bc1f3193cc 100644 (file)
@@ -42,7 +42,7 @@ var IBusManager = class {
         this._candidatePopup = new IBusCandidatePopup.CandidatePopup();
 
         this._panelService = null;
-        this._engines = {};
+        this._engines = new Map();
         this._ready = false;
         this._registerPropertiesId = 0;
         this._currentEngineName = null;
@@ -73,7 +73,7 @@ var IBusManager = class {
 
         this._panelService = null;
         this._candidatePopup.setPanelService(null);
-        this._engines = {};
+        this._engines.clear();
         this._ready = false;
         this._registerPropertiesId = 0;
         this._currentEngineName = null;
@@ -96,7 +96,7 @@ var IBusManager = class {
         if (enginesList) {
             for (let i = 0; i < enginesList.length; ++i) {
                 let name = enginesList[i].get_name();
-                this._engines[name] = enginesList[i];
+                this._engines.set(name, enginesList[i]);
             }
             this._updateReadiness();
         } else {
@@ -150,8 +150,7 @@ var IBusManager = class {
     }
 
     _updateReadiness() {
-        this._ready = (Object.keys(this._engines).length > 0 &&
-                       this._panelService != null);
+        this._ready = this._engines.size > 0 && this._panelService != null;
         this.emit('ready', this._ready);
     }
 
@@ -189,10 +188,10 @@ var IBusManager = class {
     }
 
     getEngineDesc(id) {
-        if (!this._ready || !this._engines.hasOwnProperty(id))
+        if (!this._ready || !this._engines.has(id))
             return null;
 
-        return this._engines[id];
+        return this._engines.get(id);
     }
 
     setEngine(id, callback) {